﻿using System.IO;
using NUnit.Framework;
using OpenPowerPoint;
using OpenPowerPoint.Slides;

namespace OpenPowerPointTest.Initialisation
{
    /// <summary>
    /// Tests for a presentation template containing different groups, slides and master slides
    /// </summary>
    [TestFixture]
    [Category("Integration: Initialisation")]
    public class GroupInitialisation
    {
        private Presentation _presentation;
        private Stream _stream;

        #region Setup/Teardown
        [SetUp]
        public void Setup()
        {
            _stream = new MemoryStream(Presentations.groups);

            _presentation = Presentation.LoadPresentation(_stream);
        }

        [TearDown]
        public void TearDown()
        {
            _stream.Close();
        }
        #endregion

        /// <summary>
        /// Test for the right number of groups
        /// </summary>
        /// <remarks><seealso cref="Presentation.Groups"/></remarks>
        [Test]
        public void GroupCount()
        {
            Assert.AreEqual(4, _presentation.Groups.Count, "Wrong number of groups recognized");
        }

        /// <summary>
        /// Test for the right number of slides in all groups
        /// </summary>
        /// <remarks><seealso cref="SlideGroup.Slides"/></remarks>
        [Test]
        public void GroupContent()
        {
            Assert.AreEqual(2, _presentation.Groups[0].Slides.Count, "Wrong number of slides in group 1");
            Assert.AreEqual(2, _presentation.Groups[1].Slides.Count, "Wrong number of slides in group 2");
            Assert.AreEqual(1, _presentation.Groups[2].Slides.Count, "Wrong number of slides in group 3");
            Assert.AreEqual(2, _presentation.Groups[3].Slides.Count, "Wrong number of slides in group 4");
        }

        /// <summary>
        /// Test for the right captions of the groups
        /// </summary>
        /// <remarks><seealso cref="SlideGroup.Name"/></remarks>
        [Test]
        public void GroupNamings()
        {
            Assert.AreEqual("Standardabschnitt", _presentation.Groups[0].Name, "Wrong prop for group 1");
            Assert.AreEqual("Test1", _presentation.Groups[1].Name, "Wrong prop for group 2");
            Assert.AreEqual("temp", _presentation.Groups[2].Name, "Wrong prop for group 3");
            Assert.AreEqual("last", _presentation.Groups[3].Name, "Wrong prop for group 4");
        }
    }
}
